<template>
  <el-dialog
    :title="title"
    class="add-address-dialog"
    :visible="dialogVisible"
    @close="closeDialog"
    width="600px"
  >
    <div class="price-history-wrapper">
      <ul>
        <li
          v-for="(item, index) in data"
          :key="index">
          <span>操作员：{{ item.operator }}</span>
          <span>添加销售价格为： {{ item.generalPrice }}</span>
          <span>修改时间： {{ item.time }}</span>
        </li>
      </ul>
    </div>
    <div
      slot="footer"
      class="dialog-footer">
      <el-button
        type="primary"
        @click="confirmDialog">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'PriceHistoryDialog',
  props: {
    title: {
      type: String,
      default: ''
    },
    dialogVisible: {
      type: Boolean,
      default: false
    },
    priceData: {
      type: Array,
      default: () => [
        { operator: '小明', generalPrice: 100, time: '2019-09-21' },
        { operator: '小张', generalPrice: 200, time: '2019-09-23' }
      ]
    }
  },
  data () {
    return {
      data: this.priceData
    }
  },
  watch: {
    priceData (val) {
      this.$nextTick(() => {
        this.data = val
      })
    }
  },
  methods: {
    closeDialog () {
      this.$emit('closeDialog')
    },
    confirmDialog () {
      this.$emit('confirmDialog')
    }
  }
}
</script>

<style lang="less">
.add-address-dialog {
  .address-form-wrapper {
    width: 400px;
  }

  .dialog-footer {
    text-align: center;
  }
}
</style>
